package com.ccc.demoboot.service;

import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ccc.demoboot.dao.CodeMapper;
import com.ccc.demoboot.pojo.Code;
import com.ccc.demoboot.service.CodeService;

/**
 * @Author wz
 * @Date 2024/6/12 10:47
 * @PackageName:com.ccc.demoboot.service
 * @ClassName: CodeServiceImpl
*/
@Service
public class CodeServiceImpl extends ServiceImpl<CodeMapper, Code> implements CodeService{

    @Override
    public List<Code> listmy() {

        return this.baseMapper.listmy();
    }



    @Override
    public List<Code> warecategory() {

        return this.baseMapper.warecategory();
    }

    @Override
    public String wareMaterialId(Code code) {
        Code code1 = this.baseMapper.selectById(code.getId());
        List<Code> list = this.baseMapper.codematerialid(code1);



        String codeMaterial="";
        for (Code code2 : list) {
            codeMaterial=code2.getCodematerial();
        }
        int c= Integer.valueOf(codeMaterial)+1;
        codeMaterial= String.valueOf(c);
        return codeMaterial ;
    }



    @Override
    public Code getCode(String codematerial) {
        return this.baseMapper.getCode(codematerial);
    }

    @Override
    public int selectOne(String codematerial) {
        return this.baseMapper.selectOne(codematerial);
    }

    @Override
    public int addCode(String codematerial, String materialname) {
        String codematerial1=codematerial.substring(0,codematerial.length()-3);
        Code code = this.baseMapper.getCode(codematerial1);
        Code code1=new Code();
        code1.setCodematerial(codematerial);
        code1.setMaterialfaid(code.getId());
        code1.setMaterialname(materialname);
        int insert = this.baseMapper.insert(code1);
        return insert;
    }

    @Override
    public List<Code> selectTj(String materialname) {
        return this.baseMapper.selectTj(materialname);
    }


}
